# 用户管理相关页面测试
from Lib.base.keywords import KeyWords
from selenium.webdriver.common.by import By
from Lib.common.common_function import *
from Lib.base.page_object.login_page import LonginPage
import uuid
import random


class UserManager(KeyWords):
    url = KeyWords.url + 'users?userType=0'

    # 新建部门
    def user_manager_create_department(self):
        '''
        现建部门测试
        :return:
        '''
        data = get_data_by_yaml(get_path() + r'\Data\element_data\user\create_department.yaml')
        element_operation(self, data[0]['data'])

    def user_manager_search_department_update(self):
        '''
        查看部门并修改
        :return:
        '''
        data = get_data_by_yaml(get_path() + r'\Data\element_data\user\search_and_update_department.yaml')
        element_operation(self, data[0]['data'])

    def user_manager_search_department_sort(self):
        '''
        查看部门并排序
        :return:
        '''
        data = get_data_by_yaml(get_path() + r'\Data\element_data\user\search_and_sort_department.yaml')
        element_operation(self, data[0]['data'])

    def user_manager_create_user(self):
        '''
        新建用户
        :return:
        '''
        data = get_data_by_yaml(get_path() + r'\Data\element_data\user\create_user.yaml')
        element_operation(self, data[0]['data'])

    def user_manager_user_list_search(self):
        '''
        查询用户列表
        :return:
        '''
        data = get_data_by_yaml(get_path() + r'\Data\element_data\user\user_list_and_search.yaml')
        element_operation(self, data[0]['data'])

    def user_manager_user_search_update(self):
        '''
        查询用户列表并修改用户
        :return:
        '''
        data = get_data_by_yaml(get_path() + r'\Data\element_data\user\user_search_and_update.yaml')
        element_operation(self, data[0]['data'])

    def user_manager_user_search_sort_setpassword(self):
        '''
        查询用户和为用户排序， 重置密码，禁用，删除用户
        :return:
        '''
        data = get_data_by_yaml(get_path() + r'\Data\element_data\user\user_search_and_sort_setpassword.yaml')
        element_operation(self, data[0]['data'])

    def user_manager_delete_department(self):
        '''
        删除部门
        :return:
        '''
        data = get_data_by_yaml(get_path() + r'\Data\element_data\user\search_and_delete_department.yaml')
        element_operation(self, data[0]['data'])


if __name__ == '__main__':
    driver = choose_browser()
    L = LonginPage(driver)
    L.login('kobeAdmin002', 'kobe8888')
    case = UserManager(driver)
    case.user_manager_create_department()
